package com.xjc.business.controller.stu;

import com.xjc.business.entity.vo.classadmin.ChatMsgContainer;
import com.xjc.business.entity.vo.stu.ClassAdminInfoVo;
import com.xjc.business.service.ChatMsgService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 徐锦程
 * 时间:2025-02-14 16:00
 */
@RestController
@RequestMapping("/student/windows")
public class StuWindowsController {

    @Autowired
    ChatMsgService chatMsgService;

    /**
     * 获取班级管理员名称
     * @param wxId 微信id
     * @return 数据
     */
    @GetMapping("/classAdminName/{wxId}")
    public Result<ClassAdminInfoVo> getClassAdminName(@PathVariable(value = "wxId",required = false) String wxId){
        if (wxId == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return chatMsgService.getClassAdminName(wxId);
    }

    /**
     * 获取聊天消息
     * @param wxIdKey 微信id
     * @return 数据
     */
    @GetMapping("/chatMsgContainer/{wxIdKey}")
    public Result<ChatMsgContainer> getStuChatMsgContainer(@PathVariable(value = "wxIdKey",required = false) String wxIdKey){
        if (wxIdKey == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return chatMsgService.getStuChatMsgContainer(wxIdKey);
    }
}
